package com.thank.web.acpect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * description: none
 *
 * @author thank
 * 2018/2/19 23:04
 */
@Aspect
@Component
public class TimeAspect {

    @Around("execution(* com.thank.web.controller.UserController.*(..))")
    public Object controllerMethodHandle(ProceedingJoinPoint point) throws Throwable{

        System.out.println("time aspect start");

        //拿参数
        Object[] args = point.getArgs();
        for (Object arg: args) {
            System.out.println("arg:" + arg);
        }
        long start = System.currentTimeMillis();

        // 请求接口返回值是什么, 这个Object就是什么
        Object object = point.proceed();
        System.out.println("time aspect end");
        System.out.println("time aspect 耗时: " + (System.currentTimeMillis()-start));
        return object;
    }

}
